package cn.scw.project.separate.service.impl;

import cn.scw.project.separate.domain.SaUserImg;
import cn.scw.project.separate.mapper.SaUserImgMapper;
import cn.scw.project.separate.service.SaUserImgService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class SaUserImgServiceImpl implements SaUserImgService {

    @Resource
    private SaUserImgMapper saUserImgMapper;

    @Override
    public Long save(SaUserImg user) {
        if (user.getId() != null) saUserImgMapper.update(user);
        else {
            user.setCreateDate(new Date());
            user.setIsDeleted(0);
            saUserImgMapper.insert(user);
        }
        return user.getId();
    }

    @Override
    public void delete(Long id) {
        SaUserImg user = new SaUserImg();
        user.setIsDeleted(1);
        save(user);
    }

    @Override
    public void delete(Long[] id) {
        for (Long i : id) delete(i);
    }

    @Override
    public void clear(Long id) {
        saUserImgMapper.delete(id);
    }

    @Override
    public List<SaUserImg> list(Map<String, Object> params) {
        return saUserImgMapper.list(params);
    }

    @Override
    public SaUserImg select(Long id) {
        return saUserImgMapper.select(id);
    }

    @Override
    public SaUserImg selectByUserId(Long id) {
        return saUserImgMapper.selectByUserId(id);
    }
}
